

from selenium import webdriver
import time




driver= ''
def open_browser(browser_name):
    global driver
    if browser_name.lower()=='chrome':
        driver= webdriver.Chrome('D:\\pythonglr\\python\\driver\\chromedriver.exe')
    elif browser_name.lower()=='ie':
        driver= webdriver.Chrome('D:\\pythonglr\\python\\driver\\chromedriver.exe')
    else:
        driver= webdriver.Chrome('D:\\pythonglr\\python\\driver\\chromedriver.exe')
def get(url):
    global driver
    driver.get(url)
def send(element_path,content):
    global driver
    try:
        driver.find_element_by_xpath(element_path).send_keys(content)
    except Exception as e:
        print(e)
def close():
    global driver
    driver.close()
    driver= ''
def click(element_path):
    global driver
    try:
        driver.find_element_by_xpath(element_path).click()
    except Exception as e:
        print(e)
def sleep(seconds):
    sends= int(seconds)
    time.sleep(sends)
def assert_word(key_word):
    global driver
    try:
        assert key_word in driver.page_source
    except Exception as e:
        print(e)


with open('key.txt',encoding='utf-8') as fp:
    for line in fp:
        test_step= line.strip()
        print(1,test_step)
        if len(test_step.split('||'))==1:
            command= '%s()' %test_step
        elif len(test_step.split('||'))==2:
            command='%s("%s")' %(test_step.split('||')[0],test_step.split('||')[1])
        elif len(test_step.split('||'))==3:
            command='%s("%s","%s")' %(test_step.split('||')[0],test_step.split('||')[1],test_step.split('||')[2])
        print(command)
        eval(command)




